package com.chuangjiangx.member.basic.ddd.domain.model.msg;

import com.chuangjiangx.commons.wx.msg.model.AbstractBaseData;
import com.chuangjiangx.commons.wx.msg.model.Keyword4Data;
import com.chuangjiangx.commons.wx.msg.model.MsgDataMeta;
import lombok.Data;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author cj-ch
 * @date 2018/1/31 上午11:19
 * 储值卡充值成功通知
 * 详细内容
        {{first.DATA}}
        充值时间：{{keyword1.DATA}}
        充值地址：{{keyword2.DATA}}
        充值金额：{{keyword3.DATA}}
        账户余额：{{keyword4.DATA}}
        {{remark.DATA}}
    内容示例
        尊敬的会员，您已成功充值。
        充值时间：2014年7月21日 18:36
        充值地址：某某商户某某分店
        充值金额：1000元
        账户余额：1031元
        如有疑问，请咨询10086
 */
@Data
public class MbrCardRechargeMsg  extends AbstractMbrWXMsg {
    /**
     * 标题
     *
     */
    private String title = "您好,您已成功充值.";
    /**
     * 充值时间
     */
    private Date rechargeTime;
    /**
     * 充值地址
     */
    private String rechargeAddress;
    /**
     * 充值金额
     */
    private BigDecimal rechargeAmount;
    /**
     * 账户余额
     */
    private BigDecimal accountBalance;
    /**
     * 备注
     */
    private String remark = "感谢您的使用";

    public MbrCardRechargeMsg(Date rechargeTime, String rechargeAddress, BigDecimal rechargeAmount, BigDecimal accountBalance) {
        this.rechargeTime = rechargeTime;
        this.rechargeAddress = rechargeAddress;
        this.rechargeAmount = rechargeAmount;
        this.accountBalance = accountBalance;
    }

    @Override
    public AbstractBaseData toMsgData(){

        Keyword4Data data = new Keyword4Data();
        data.setFirst(new MsgDataMeta(title));
        //获取时间
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        data.setKeyword1(new MsgDataMeta(format.format(rechargeTime)));
        data.setKeyword2(new MsgDataMeta(rechargeAddress));
        data.setKeyword3(new MsgDataMeta(String.valueOf(rechargeAmount)));
        data.setKeyword4(new MsgDataMeta(String.valueOf(accountBalance)));
        data.setRemark(new MsgDataMeta(remark));
        return data;
    }

    @Override
    public WXMsg getWXMsg() {
        return WXMsg.MBR_CARD_RECHARGE;
    }
}
